﻿<UserControl x:Class="Microsoft.Research.ScientificWorkflow.UIDesigner.Monitor.DataProductsView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Converters="clr-namespace:Microsoft.Research.ScientificWorkflow.UIDesigner.Monitor"
    Height="Auto" Width="Auto">
    <UserControl.Resources>
        <Style TargetType="TreeViewItem" BasedOn="{StaticResource {x:Type TreeViewItem}}">
            <Setter Property="AutomationProperties.AutomationId" Value="{Binding Path=ActivityName}"/>
            <Setter Property="AutomationProperties.Name" Value="{Binding Path=Name}"/>
        </Style>
        <Converters:ComplexDataTemplateSelector x:Key="ComplexDatatypeSelector"></Converters:ComplexDataTemplateSelector>
        
        <DataTemplate x:Key="DataProductItem_template">
            <DockPanel Margin="0,2,0,2" >
                <Image Source="{Binding Path=ImageSource}" Width="18" Height="18"
                       Cursor="Hand" MouseLeftButtonDown="OnLinkClick"/>
                <TextBlock Text="{Binding Path=Name}" VerticalAlignment="Center" 
                    Foreground="Blue" TextDecorations="Underline" Cursor="Hand" MouseLeftButtonDown="OnLinkClick"/>
            </DockPanel>
        </DataTemplate>


        <HierarchicalDataTemplate x:Key="DataProductViewModel_template" ItemsSource="{Binding Path=DisplayItems}" ItemTemplateSelector="{StaticResource ComplexDatatypeSelector}">
            <DockPanel Margin="0,2,0,2" >
                <Image Source="/Microsoft.Research.ScientificWorkflow.TridentUtilities;component/Images/ScientificWorkflow/DataStoreICon.png" Margin="0,0,5,0" />
                <TextBlock Text="{Binding Path=ActivityLabel}" VerticalAlignment="Center" />
             </DockPanel>
        </HierarchicalDataTemplate>
        
        <HierarchicalDataTemplate x:Key="DataProductIterationViewModel_template" ItemsSource="{Binding Path=DataproductViewModels}" ItemTemplate="{StaticResource DataProductViewModel_template}">
            <DockPanel Margin="0,2,0,2">
                <Image Source="/Microsoft.Research.ScientificWorkflow.TridentUtilities;component/Images/ScientificWorkflow/DataStoreICon.png" 
                       Margin="0,0,5,0"/>
                <TextBlock Text="{Binding Path=Name}"/>
            </DockPanel>
        </HierarchicalDataTemplate>

        
    </UserControl.Resources>
    <Border BorderThickness=".5" BorderBrush="Black">
        <Grid>
            <Border BorderThickness="1,1,1,1" AutomationProperties.AutomationId="AIdDataProduct">
                <TreeView Margin="0,0,0,0" AutomationProperties.AutomationId="dataProductTree" 
                          ItemTemplate="{StaticResource DataProductViewModel_template}" ItemsSource="{Binding Path=DataProductsViewCollection}" 
                          Name="dataproductTree" HorizontalAlignment="Stretch" />
            </Border>
        </Grid>
    </Border>
</UserControl>
